﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Utils.MathUtilitys
{
    public static class Vec2Utils
    {
        public static Vector2 Rotate(Vector2 vec, float rad)
        {
            float cos = MathUtils.FCos(rad);
            float sin = MathUtils.FSin(rad);

            return new Vector2(cos * vec.X - sin * vec.Y, sin * vec.X + cos * vec.Y);
        }

        public static float Vec2ToAngle(Vector2 vec)
        {
            return MathUtils.FAtan2(vec.Y, vec.X);
        }

        public static Vector2 AngleToVec2(float angle)
        {
            return new Vector2(MathUtils.FCos(angle), MathUtils.FSin(angle));
        }

        public static Vector2 Interpolate(Vector2 vecA, Vector2 vecB, float per)
        {
            return vecA * (1 - per) + vecB * per;
        }
    }
}
